package main

import (
	"fmt"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
	"gitee.com/shexk/sfp/stl"
)

func main() {
	// 创建一个新的Fyne应用
	myApp := app.New()
	// 创建主窗口，设置标题
	myWindow := myApp.NewWindow("Small Frame Plugins")
	// 创建多行文本框
	textArea := widget.NewMultiLineEntry()

	scroll := container.NewScroll(textArea)
	scroll.SetMinSize(fyne.NewSize(600, 400)) // 设置最小尺寸

	// 创建主容器，垂直排列按钮和文本框
	mainContainer := container.NewVBox(
		scroll,
	)

	line := 1
	stl.GetLog().Start(func(s string) {
		fyne.Do(func() {
			line_text := fmt.Sprintf("[%d]", line)
			textArea.SetText(line_text + s + textArea.Text)
			if line%100 == 0 {
				textArea.SetText("")
			}
			line++
		})
	})

	stl.GetLog().WriteLog(stl.Log_Debug, "Welcome To Small Frame Plugins")
	GetApp().Start()

	myWindow.SetFixedSize(true)

	// 设置窗口内容并显示
	myWindow.CenterOnScreen()
	myWindow.SetContent(mainContainer)
	myWindow.Resize(fyne.NewSize(600, 400)) // 设置初始窗口大小

	myWindow.SetOnClosed(func() {

	})
	myWindow.Show()

	myApp.Run()
}

//打包程序：linux fyne package -os linux -icon app.ico
//Mac ../../../go/bin/fyne package -os darwin -icon app.ico
//windows fyne package -os windows -icon app.ico
